const path = require('path')

function resolve (dir) {
  return path.join(__dirname, dir)
}

module.exports = {
  publicPath: '/cfpc',
  outputDir: '../cfpc-dist/cfpc/',
  assetsDir: 'static',
  indexPath: 'index.html',
  lintOnSave: false,
  productionSourceMap: false,
  // 导出配置
  devServer: {
    open: true,
    proxy: {
      '/api': {
        target: 'https://ticket.cfexpo2021.com',
        pathRewrite: { '^/api': '' },
        secure: true, // 默认值  true
        changeOrigin: true // 默认值 true
      }
    }
  },
  configureWebpack: (config) => {
    // console.log(config)
    // config.mode = 'development'
    // 如果当前是生产模式
    if (process.env.NODE_ENV === 'production') {
      // 删除console
      config.optimization.minimizer[0].options.terserOptions.compress.drop_console = true
      // 删除debugger
      config.optimization.minimizer[0].options.terserOptions.compress.drop_debugger = true
    }
  },
  chainWebpack: (config) => {
    // 修改文件引入自定义路径
    if (process.env.NODE_ENV === 'production') {
      config.resolve.alias.set('@base', resolve('src/const/base.product.js'))
    } else if (process.env.NODE_ENV === 'development') {
      config.resolve.alias.set('@base', resolve('src/const/base.dev.js'))
    }
  }
}
